home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / ileave.arc / ILEAVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-07  |  3.7 KB  |  190 lines

  1. /*  This version (1.20) reworked for Turbo 'C' for speed */
  2.  
  3. /*  D. Bushong  (c) 1987 All rights reserved.  OK to distribute, providing
  4. that these comments remain intact, and that copyright notice is displayed
  5. intact.
  6. */
  7.  
  8. #define MYVERSION "Version 1.20"
  9. #include <stdio.h>
  10. #include <dos.h>    
  11. #include <hamdefs.h>
  12.  
  13. void interrupt terminate(void);
  14. void interrupt (*oldvect)(void);
  15.  
  16. char    *options[] = {
  17.     "Read WARNING message",
  18.     "Read \"What is interleave?\"",
  19.     "Read \"Why change interleave?\"",
  20.     "Select the disk drive",
  21.     "Execute interleave adjustment",
  22.     "Exit this program",
  23.     NULL
  24. };
  25.  
  26.  
  27. int    drive_to_use = 0x80;
  28. int    have_selected = 0;
  29. int    factor;
  30. unsigned char    s_top, s_bottom;
  31.  
  32. main(argc, argv)
  33. int    argc;
  34. char    **argv;
  35. {
  36.     static int    colarray[] = {
  37.         39    };
  38.     int    choice;
  39.     char    temp[80];
  40.  
  41.     _AX = 0x0300;
  42.     _BX = 0;
  43.     geninterrupt(0x10);
  44.  
  45.     s_top = _CH;
  46.     s_bottom = _CL;
  47.  
  48.     if (argc == 2)
  49.         sscanf(argv[1], "%d", &factor);
  50.  
  51.     if (factor < 1 || factor > 16 || argc != 2)
  52.         factor = 5;
  53.  
  54.     clrscn();
  55.     scrbox(0, 0, 23, 79, 2, NORMAL | HILITE);
  56.     center(9, "RADIO KZ1O");
  57.     center(10, "Concord, NH U.S.A. 03301");
  58.     center(6, "Interleave Adjust Utility (IAU.EXE)");
  59.     center(12, "(c) 1987 Dave Bushong, All Rights Reserved");
  60.     center(13, MYVERSION);
  61.  
  62.     locate(17, 5);
  63.     keyboard();    /* press a key */
  64.  
  65.     clrscn();
  66.  
  67.     oldvect = getvect(0x23);
  68.     setvect(0x23, terminate);
  69.  
  70.     scrtable(0, 0, 23, 78, 3, NORMAL | HILITE, 5, 7, -1, 1, colarray);
  71.  
  72.     atputsa(1, 37, "Status", NORMAL | HILITE);
  73.     atputsa(6, 15, "Selection", NORMAL | HILITE);
  74.     atputsa(6, 54, "Information", NORMAL | HILITE);
  75.  
  76.     type("warning.doc", 10, 43, 20, 75);
  77.  
  78.     locate(9, 5);
  79.  
  80.     choice = 0;
  81.     clrkey();
  82.     while ((choice = getbar(options, choice)) != 5) {
  83.         switch (choice) {
  84.         case 0:    
  85.             type("warning.doc", 10, 43, 20, 75);
  86.             break;
  87.         case 1:    
  88.             type("ileave.doc", 10, 43, 20, 75);
  89.             sprintf(temp, "Interleave selected: %d", factor);
  90.             atputsha(21, 42, temp);
  91.             break;
  92.         case 2:    
  93.             type("change.doc", 10, 43, 20, 75);
  94.             break;
  95.         case 3:    
  96.             sel_disk();
  97.             break;
  98.         case 4:    
  99.             clrblk(12, 45, 14, 75);
  100.             atputsha(17, 45, "Started  at ");
  101.             showtime(17, 58);
  102.             rfw();
  103.             atputsha(13, 45, "Complete at ");
  104.             showtime(13, 58);
  105.             choice = 5;
  106.             break;
  107.         case 5:    
  108.             cursor(TRUE);
  109.         default:    
  110.             break;
  111.         }
  112.         clrblk(1, 1, 4, 77);
  113.         atputsa(1, 37, "Status", NORMAL | HILITE);
  114.         center(3, "Complete");
  115.         locate(9, 5);
  116.         clrkey();
  117.     }
  118.  
  119.     locate(23, 0);
  120.     setvect(0x23, oldvect);
  121.     cursor(TRUE);
  122.     exit(0);
  123. }
  124.  
  125.  
  126. char    *pick_disk[] = {
  127.     "Select the first hard disk drive ",
  128.     "Select the second hard disk drive",
  129.     NULL
  130. };
  131.  
  132.  
  133. sel_disk()
  134. {
  135.     struct REGPACK r;
  136.     struct SREGS sregs;
  137.  
  138.     int    count;
  139.     char    temp[80];
  140.  
  141.     segread(&sregs);
  142.     r.r_ax = 0x0800;
  143.     r.r_bx = r.r_cx = 0;
  144.     r.r_dx = drive_to_use;
  145.     intr(0x13, &r);
  146.     if (r.r_flags & 1) {
  147.         atputsa(2, 25, "Unable to address hard disk(s)", NORMAL | HILITE);
  148.         beep();
  149.         return;
  150.     }
  151.     count = r.r_dx & 0x0f;
  152.  
  153.     atputsha(22, 42, "Drive selected: ");
  154.     switch (count) {
  155.     case 0:    
  156.         center(3, "No hard disk drives in your system");
  157.         break;
  158.     case 1:
  159.         break;
  160.     case 2:
  161.         locate(19, 5);
  162.         drive_to_use = 0x80 + getbar(pick_disk, 0);
  163.         clrblk(18, 4, 22, 5 + strlen(pick_disk[0]));
  164.         break;
  165.     default:
  166.         clrscn();
  167.         atputsa(5, 5, "Congratulations! You have more than two hard", NORMAL | HILITE);
  168.         atputsa(6, 5, "disks responding, and that BREAKS this program.", NORMAL | HILITE);
  169.         locate(23, 0);
  170.         setvect(0x23, oldvect);
  171.         exit(9);
  172.         break;
  173.  
  174.     }
  175.     sprintf(temp, "%02d", drive_to_use - 0x80);
  176.     atputsa(22, 58, temp, NORMAL | HILITE);
  177.     have_selected = 1;
  178. }
  179.  
  180.  
  181. cursor(int onoff)
  182. {
  183.     if (onoff)
  184.         v_scsrtp(s_top, s_bottom);
  185.     else
  186.         v_scsrtp(0x20, 7);
  187. }
  188.  
  189.  
  190.